package org.finalministry.gui.action;

import geodb.GeoDB;

import java.io.IOException;
import java.sql.SQLException;

import org.finalministry.database.FinalministryDatabase;
import org.finalministry.database.connection.FinalministryDatabaseConnection;
import org.finalministry.database.dao.DaoFactory;
import org.finalministry.utils.DatabaseInitializer;
import org.junit.BeforeClass;
import org.junit.Test;

public class ExportKMLfileActionTest {

	@BeforeClass
	public static void prepare() throws ClassNotFoundException, SQLException, IOException {
		FinalministryDatabase database = new FinalministryDatabase("finalministryTest", "sa", "sa", 7786);
		database.start();
		DaoFactory.setFinalMinistryConnection(new FinalministryDatabaseConnection("finalministryTest", "sa", "sa", 7786));
		DaoFactory.getInstance();
		System.out.println(DaoFactory.getInstance().isConnectionActive());
		// DatabaseInitializer.forceDatabaseInitialization(DaoFactory.getFinalMinistryConnection());
		DatabaseInitializer.forceDatabaseSpatialOnlyInitialization(DaoFactory.getFinalMinistryConnection());

		/*
		 * DAS IST DER FIX !!!
		 */
		GeoDB.InitGeoDB(DaoFactory.getFinalMinistryConnection().getConnection());
	}

	@Test
	public void testKMLExport() throws Exception {

		ExportasKMLfileAction exportasKMLfileAction = new ExportasKMLfileAction(null);
		exportasKMLfileAction.exportTerritoriesAsKML(null);
	}
}
